package interview.dfs;

import java.util.*;

/**
 * 魔法之树 https://codefun2000.com/p/P1224
 */
public class MagicTree {

    static long n,l,r, count;
    static List<List<Integer>> childsList;
    static int[] weights;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        l = sc.nextLong();//看数据范围，10^14超过了int的范围10^9，故需使用Long类型
        r = sc.nextLong();
        String s = sc.next();weights = new int[s.length()+1];
        for (int i = 1;i <= s.length();i++)
            weights[i] = s.charAt(i-1) - '0';
        childsList = new ArrayList<>();
        for (int i = 0;i <= n;i++) {
            childsList.add(new ArrayList<>());
        }
        for (int i = 1;i <= n-1;i++) {
            int u = sc.nextInt();
            int v = sc.nextInt();
            childsList.get(u).add(v);
            childsList.get(v).add(u);
        }
        //遍历所有节点作为起点的情况
        for (int root = 1;root <= n;root++) {
            dfs(root, -1, 0, 1);
        }
        System.out.println(count);
    }

    /**
     * 前序遍历获得以root根节点为起点的所有路径
     */
    public static void dfs(int root, int fa, long curVal, int len) {
        curVal = curVal*2 + weights[root];
        if (curVal > r) return;
        if (curVal >= l && len >= 2)
            count++;
        List<Integer> childs = childsList.get(root);
        for (Integer child : childs) {
            if (child == fa) continue;
            dfs(child, root, curVal, ++len);//注意传递参数时++len和len++的区别
        }
    }
}
